<template>
	<view class="waterfall-item" @tap="onTap">
		<image :src="params.url" mode="widthFix" @load="emitHeight" @error="emitHeight"></image>
		<view class="content">
			<view class="title u-line-2">{{params.title}}</view>
			<view class="money">
				<text style="font-size: 36rpx;padding-right: 4rpx;font-weight: bold;">3200</text>	
				<text style="font-size: 24rpx;">积分</text>
			</view>
			<view class="shop-name u-border">积分+现金</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"helang-waterfall",
		props:{
			params:{
				type: Object,
				default(){
					return {}
				}
			},
			tag:{
				type:String | Number,
				default:''
			},
			index:{
				type:Number,
				default:-1
			}
		},
		data() {
			return {
				
			};
		},
		methods:{
			// 发出组件高度信息，在此处可以区分正确和错误的加载，给予错误的提示图片
			emitHeight(e){
				const query = uni.createSelectorQuery().in(this);
				query.select('.waterfall-item').boundingClientRect(data => {
					let height = Math.floor(data.height);
					this.$emit("height",height,this.$props.tag);
				}).exec();
			},
			onTap(){
				this.$emit("click",this.$props.index,this.$props.tag);
			}
		}
	}
</script>

<style lang="scss">
	.u-border {
		border-color: $u-primary!important;
	}
</style>

<style lang="scss" scoped>
.waterfall-item{
	background-color: #fff;
	border-radius: 8px;
	font-size: 28rpx;
	color: #666;
	margin-bottom: 16rpx;
	overflow: hidden;
	
	image{
		display: block;
		width: 100%;
		// 默认设置一个图片的大约值
		height: 350rpx;
	}
	
	.content{
		padding: 16rpx;
		.title {
			color: #000;
			line-height: 32rpx;
		}
		.money{
			color: $uni-color-primary;
			margin-top: 8rpx;
		}
		
		.label{
			background-color: $uni-color-primary;
			color: #fff;
			font-size: 20rpx;
			padding: 4rpx 16rpx;
			border-radius: 20rpx;
		}
		
		.shop-name{
			font-size: 20rpx;
			color: $u-primary;
			display: inline-block;
			padding: 4rpx;
			border-radius: 4rpx;
			line-height: 20rpx;
		}
	}
}
</style>
